<template>
	<div class="home_h">
		 <header class="m_header">
                <div class="m_header_box" id="my_search">
                    <a href="#" class="icon_logo"></a>
                    <form action="#">
                        <span class="icon_search"></span>
                        <input type="search" class="search" placeholder="点击搜索" @click="goSearch($event)">
                    </form>
                    <a style="cursor:pointer" class="logo_btn" @click="loginout">{{username}}</a>
                </div>
            </header>
	</div>
</template>
<script>
import { mapState, mapGetters, mapActions } from 'vuex'
export default {
        data () {
            return {
            }
        },
        computed:{
            ...mapState({
                username:state => state.mutations.userInfo.user_name
            })
            },
        mounted () {
        },
        methods:{
            goSearch(event){
                this.$router.push('/search');
                window.event? window.event.returnValue = false : event.preventDefault();
            },
            loginout () {
                this.$store.dispatch('logout').then(() => {
                    this.$router.push('/login')
                })
            }
        }
    }
</script>